﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DAL;

namespace logic
{
   public class returnProduct
    {
       /// <summary>
       /// 
       /// </summary>
       /// <param name="OrderNo"></param>
        /// <returns>0：未生成应收款，可以退货，1:已生成应收款，无法退货,2:订单未交易成功或交易关闭状态</returns>
       public static int P_Order_ReturnProduct(string OrderNo)
       {
           int Istatus = 2;//默认为2,为2代表该订单未交易成功或交易关闭状态
           DataRow rows = DAL.ReturnProduct.P_Order_ReturnProduct(OrderNo);
           if (rows != null)
           {
               int.TryParse(rows["isStatus"].ToString(), out Istatus);
           }
           return Istatus;
       }
      

       /// <summary>
       /// 返回0为不能退货
       /// </summary>
       /// <param name="oiid"></param>
       /// <param name="adminid"></param>
       /// <param name="notes"></param>
       /// <param name="quantity"></param>
       /// <returns></returns>
       public static int P_order_returnPros_IsByProcessing(int oiid, int adminid, string notes,decimal quantity)
       {
           int Istatus = 0;//0不能退货，1代表退货成功
           DataRow rows = DAL.ReturnProduct.P_order_returnPros_IsByProcessing(oiid, adminid, notes, quantity);
           if (rows != null)
           {
               int.TryParse(rows["status"].ToString(), out Istatus);
           }
           return Istatus;
       } 

       public static int P_Order_getByOrderNo(string OrderNo)
       {
           DataTable dt=DAL.ReturnProduct.P_Order_getByOrderNo(OrderNo);
           return dt != null ? dt.Rows.Count : 0;
       }

    }
}
